<?php
// exceptions for client
class SPRPC_Exception_Client extends exception
{
    /**
     * the request xml
     * @var str
     */
    protected $_req = null;


    /**
     * the response xml
     * @var str
     */
    protected $_resp = null;


    /**
     * carries information about the request, response...
     * @param $message the message
     * @param $code    the code
     * @param $request the request xml
     * @param $reponse the response xml
     */
    public function __construct($message = 'client exception', $code = 0, $request = null, $response = null)
    {
        parent::__construct($message, $code);
        $this->_req  = $request;
        $this->_resp = $response;

    }// end __cosntruct


    /**
     * get request
     * @param $beautify if true, beautify
     * @return str
     */
    public function getRequest($beautify = false)
    {
        return $this->_beautify($this->_req, $beautify);

    }// end getRequest


    /**
     * get response
     * @param $beautify if true, beautify
     * @return str
     */
    public function getResponse($beautify = false)
    {
        return $this->_beautify($this->_resp, $beautify);

    }// end getResponse


    /**
     * beautify xml..
     * @param $xml the xml
     * @param $yes if true, do it. otherwise just the old xml...
     */
    protected function _beautify($xml, $yes = true)
    {
        if ($yes && !empty($xml)) {
            $xml = '<pre>' . htmlentities(str_replace('><', ">\n<", $xml)) . '</pre>';
        }

        return $xml;

    }// end _beautify

}// end SPRPC_Exception_Client
?>